/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package IFSv2.Operations;

//import IFS.Forms.frmaphdr;
import IFSv2.Connection.DBConnection;
import IFSv2.Forms.frmAPhdr;
import IFSv2.Models.mdlLogin;
import IFSv2.Util.utilData;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;


public class clsAPhdr{

    ResultSet rsDetail;

    private String m_strBatNbr;
    private String m_strVoucherNbr;
    private String m_strVoucherDate;
    private String m_strTranType;
    private String m_strDocStatus;
    private String m_strCompanyID;
    private String m_strBranchID;
    private String m_strVendorID;
    private String m_strSubLedger;
    private String m_strInvoice;
    private String m_strInvoiceDate;
    private String m_strTermsID;
    private String m_strDueDate;
    private String m_strTaxable;
    private String m_strVAT;
    private String m_strWTax;
    private String m_strAmount;
    private String m_strCreditAmt;
    private String m_strDetails;
    private String m_strDocType;
    private String m_strCurrencyCode;
    private String m_strExchangeRate;
    private String m_strOKToPost;
    private String m_strRecurrID;
    private String m_strPosted;
    private String m_strTaxableAmount01;
    private String m_strTaxableAmount02;
    private String m_strTaxableAmount03;
    private String m_strTaxableAmount04;
    private String m_strTotalTaxable01;
    private String m_strTotalTaxable02;
    private String m_strTaxAmount01;
    private String m_strTaxAmount02;
    private String m_strTaxAmount03;
    private String m_strTaxAmount04;
    private String m_strTotalTax01;
    private String m_strTotalTax02;
    private String m_strOffSet;
    private String m_strSeqID;
    
    private String m_strInsertList;
    private String m_strSelectList;
    private String m_strTableName;
    
    List<String> m_arrDataTypeList = new ArrayList<>();
    List<String> m_arrColumnNameList = new ArrayList<>();

    //<editor-fold defaultstate="collapsed" desc="Getter/Setter">
    
    public void setOffSet(String m_strOffSet){
        this.m_strOffSet = m_strOffSet;
    }
    
    public String getOffSet(){
        return m_strOffSet;
    }
    
    public void setSubLedger(String m_strSubLedger){
        this.m_strSubLedger = m_strSubLedger;
    }
    
    public void setTaxable(String m_strTaxable) {
        this.m_strTaxable = m_strTaxable;
    }

    public void setVAT(String m_strVAT) {
        this.m_strVAT = m_strVAT;
    }

    public void setWTAX(String m_strWTAX) {
        this.m_strWTax = m_strWTAX;
    }
    public String getSubLedger(){
        return m_strSubLedger;
    }
    
    public String getTaxable() {
        return m_strTaxable;
    }

    public String getVAT() {
        return m_strVAT;
    }

    public String getWTAX() {
        return m_strWTax;
    }
    
    public ResultSet getDetail() {
        return rsDetail;
    }

    public String getTableName() {
        return m_strTableName;
    }

    public void setTableName(String strTableName) {
        this.m_strTableName = strTableName;
    }

    public String getBatNbr() {
        return m_strBatNbr;
    }

    public void setBatNbr(String strBatNbr) {
        this.m_strBatNbr = strBatNbr;
    }

    public String getVoucherNbr() {
        return m_strVoucherNbr;
    }

    public void setVoucherNbr(String strVoucherNbr) {
        this.m_strVoucherNbr = strVoucherNbr;
    }

    public String getVoucherDate() {
        return m_strVoucherDate;
    }

    public void setVoucherDate(String strVoucherDate) {
        this.m_strVoucherDate = strVoucherDate;
    }

    public String getTranType() {
        return m_strTranType;
    }

    public void setTranType(String strTranType) {
        this.m_strTranType = strTranType;
    }

    public String getRecurrID() {
        return m_strRecurrID;
    }

    public void setRecurrID(String strRecurrID) {
        this.m_strRecurrID = strRecurrID;
    }

    public String getVendorID() {
        return m_strVendorID;
    }

    public void setVendorID(String strVendorID) {
        this.m_strVendorID = strVendorID;
    }

    public String getInvoice() {
        return m_strInvoice;
    }

    public void setInvoice(String strInvoice) {
        this.m_strInvoice = strInvoice;
    }

    public String getInvoiceDate() {
        return m_strInvoiceDate;
    }

    public void setInvoiceDate(String strInvoiceDate) {
        this.m_strInvoiceDate = strInvoiceDate;
    }

    public String getTermsID() {
        return m_strTermsID;
    }

    public void setTermsID(String strTermsID) {
        this.m_strTermsID = strTermsID;
    }

    public String getDueDate() {
        return m_strDueDate;
    }

    public void setDueDate(String strDueDate) {
        this.m_strDueDate = strDueDate;
    }

    public String getTaxableAmount01() {
        return m_strTaxableAmount01;
    }

    public void setTaxableAmount01(String strTaxableAmount01) {
        this.m_strTaxableAmount01 = strTaxableAmount01;
    }

    public String getTaxableAmount02() {
        return m_strTaxableAmount02;
    }

    public void setTaxableAmount02(String strTaxableAmount02) {
        this.m_strTaxableAmount02 = strTaxableAmount02;
    }

    public String getTaxableAmount03() {
        return m_strTaxableAmount03;
    }

    public void setTaxableAmount03(String strTaxableAmount03) {
        this.m_strTaxableAmount03 = strTaxableAmount03;
    }

    public String getTaxableAmount04() {
        return m_strTaxableAmount04;
    }

    public void setTaxableAmount04(String strTaxableAmount04) {
        this.m_strTaxableAmount04 = strTaxableAmount04;
    }

    public String getTotalTaxable01() {
        return m_strTotalTaxable01;
    }

    public void setTotalTaxable01(String strTotalTaxable01) {
        this.m_strTotalTaxable01 = strTotalTaxable01;
    }

    public String getTotalTaxable02() {
        return m_strTotalTaxable02;
    }

    public void setTotalTaxable02(String strTotalTaxable02) {
        this.m_strTotalTaxable02 = strTotalTaxable02;
    }

    public String getTaxAmount01() {
        return m_strTaxAmount01;
    }

    public void setTaxAmount01(String strTaxAmount01) {
        this.m_strTaxAmount01 = strTaxAmount01;
    }

    public String getTaxAmount02() {
        return m_strTaxAmount02;
    }

    public void setTaxAmount02(String strTaxAmount02) {
        this.m_strTaxAmount02 = strTaxAmount02;
    }

    public String getTaxAmount03() {
        return m_strTaxAmount03;
    }

    public void setTaxAmount03(String strTaxAmount03) {
        this.m_strTaxAmount03 = strTaxAmount03;
    }

    public String getTaxAmount04() {
        return m_strTaxAmount04;
    }

    public void setTaxAmount04(String strTaxAmount04) {
        this.m_strTaxAmount04 = strTaxAmount04;
    }

    public String getTotalTax01() {
        return m_strTotalTax01;
    }

    public void setTotalTax01(String strTotalTax01) {
        this.m_strTotalTax01 = strTotalTax01;
    }

    public String getTotalTax02() {
        return m_strTotalTax02;
    }

    public void setTotalTax02(String strTotalTax02) {
        this.m_strTotalTax02 = strTotalTax02;
    }

    public String getAmount() {
        return m_strAmount;
    }

    public void setAmount(String strAmount) {
        this.m_strAmount = strAmount;
    }

    public String getCreditAmt() {
        return m_strCreditAmt;
    }

    public void setCreditAmt(String strCreditAmt) {
        this.m_strCreditAmt = strCreditAmt;
    }

    public String getDetails() {
        return m_strDetails;
    }

    public void setDetails(String strDetails) {
        this.m_strDetails = strDetails;
    }

    public String getDocType() {
        return m_strDocType;
    }

    public void setDocType(String strDocType) {
        this.m_strDocType = strDocType;
    }

    public String getCompanyID() {
        return m_strCompanyID;
    }

    public void setCompanyID(String strCompanyID) {
        this.m_strCompanyID = strCompanyID;
    }

    public String getBranchID() {
        return m_strBranchID;
    }

    public void setBranchID(String strBranchID) {
        this.m_strBranchID = strBranchID;
    }

    public String getCurrencyCode() {
        return m_strCurrencyCode;
    }

    public void setCurrencyCode(String strCurrencyCode) {
        this.m_strCurrencyCode = strCurrencyCode;
    }

    public String getExchangeRate() {
        return m_strExchangeRate;
    }

    public void setExchangeRate(String strExchangeRate) {
        this.m_strExchangeRate = strExchangeRate;
    }

    public String getDocStatus() {
        return m_strDocStatus;
    }

    public void setDocStatus(String strDocStatus) {
        this.m_strDocStatus = strDocStatus;
    }

    public String getOKToPost() {
        return m_strOKToPost;
    }

    public void setOKToPost(String strOKToPost) {
        this.m_strOKToPost = strOKToPost;
    }

    public String getPosted() {
        return m_strPosted;
    }

    public void setPosted(String strPosted) {
        this.m_strPosted = strPosted;
    }

    public String getSeqID() {
        return m_strSeqID;
    }

    public void setSeqID(String strSeqID) {
        this.m_strSeqID = strSeqID;
    }


    //</editor-fold>

    //Constructor
    public clsAPhdr(){
        m_strTableName = "aphdr";
        m_strInsertList = "BatNbr"
                + ", VoucherNbr"
                + ", VoucherDate"
                + ", TranType"
                + ", RecurrID"
                + ", VendorID"
                + ", SubLedger"
                + ", Invoice"
                + ", InvoiceDate"
                + ", TermsID"
                + ", DueDate"
                + ", TaxableAmount01"
                + ", TaxableAmount02"
                + ", TaxableAmount03"
                + ", TaxableAmount04"
                + ", TotalTaxable01"
                + ", TotalTaxable02"
                + ", TaxAmount01"
                + ", TaxAmount02"
                + ", TaxAmount03"
                + ", TaxAmount04"
                + ", TotalTax01"
                + ", TotalTax02"
                + ", Amount"
                + ", CreditAmt"
                + ", Details"
                + ", DocType"
                + ", CompanyID"
                + ", BranchID"
                + ", CurrencyCode"
                + ", ExchangeRate"
                + ", DocStatus"
                + ", OKToPost"
                + ", Posted"
                + ", Taxable"
                + ", VAT"
                + ", WTax"
                + ", OffSet"
                + ", UserStamp"
                + ", TimeStamp"
                ;
        m_strSelectList = "BatNbr"
                + ", VoucherNbr"
                + ", VoucherDate"
                + ", TranType"
                + ", RecurrID"
                + ", VendorID"
                + ", SubLedger"
                + ", Invoice"
                + ", InvoiceDate"
                + ", TermsID"
                + ", DueDate"
                + ", TaxableAmount01"
                + ", TaxableAmount02"
                + ", TaxableAmount03"
                + ", TaxableAmount04"
                + ", TotalTaxable01"
                + ", TotalTaxable02"
                + ", TaxAmount01"
                + ", TaxAmount02"
                + ", TaxAmount03"
                + ", TaxAmount04"
                + ", TotalTax01"
                + ", TotalTax02"
                + ", Amount"
                + ", CreditAmt"
                + ", Details"
                + ", DocType"
                + ", CompanyID"
                + ", BranchID"
                + ", CurrencyCode"
                + ", ExchangeRate"
                + ", DocStatus"
                + ", OKToPost"
                + ", Posted"
                + ", Taxable"
                + ", VAT"
                + ", WTax"
                + ", OffSet"
                + ", SeqID"
                ;

        ResultSet rsTable;
        ResultSetMetaData rsmdTable;

        try {
            String strSQL = "SELECT " + m_strSelectList + " FROM " + m_strTableName + " LIMIT 1";
            rsTable = DBConnection.getActiveConnection().createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY).executeQuery(strSQL);
            rsmdTable = rsTable.getMetaData();
            
            int intNumCol = rsmdTable.getColumnCount();
            
            for(int intIndex = 1; intIndex <= intNumCol; intIndex++){
                m_arrDataTypeList.add(rsmdTable.getColumnTypeName(intIndex));
                m_arrColumnNameList.add(rsmdTable.getColumnName(intIndex));
            }
            rsTable.close();
        }
        catch (SQLException ex) {
            Logger.getLogger(clsAPhdr.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void clearFieldProperties(){
        m_strBatNbr = "";
        m_strVoucherNbr = "";
        m_strVoucherDate = "";
        m_strTranType = "";
        m_strRecurrID = "";
        m_strVendorID = "";
        m_strSubLedger = "";
        m_strInvoice = "";
        m_strInvoiceDate = "";
        m_strTermsID = "";
        m_strDueDate = "";
        m_strTaxableAmount01 = "";
        m_strTaxableAmount02 = "";
        m_strTaxableAmount03 = "";
        m_strTaxableAmount04 = "";
        m_strTotalTaxable01 = "";
        m_strTotalTaxable02 = "";
        m_strTaxAmount01 = "";
        m_strTaxAmount02 = "";
        m_strTaxAmount03 = "";
        m_strTaxAmount04 = "";
        m_strTotalTax01 = "";
        m_strTotalTax02 = "";
        m_strAmount = "";
        m_strCreditAmt = "";
        m_strDetails = "";
        m_strDocType = "";
        m_strCompanyID = "";
        m_strBranchID = "";
        m_strCurrencyCode = "";
        m_strExchangeRate = "";
        m_strDocStatus = "";
        m_strOKToPost = "";
        m_strPosted = "";
        m_strVAT = "";
        m_strWTax = "";
        m_strTaxable = "";
        m_strOffSet = "";
        m_strSeqID = "";
    }

    public String getDataTypeName(String strColumn){
        int intIndex = m_arrColumnNameList.indexOf(strColumn);
        return m_arrDataTypeList.get(intIndex);
    }

    public boolean deleteRow(){ 
        String strSQL = "DELETE FROM " + 
        	m_strTableName +
            " WHERE BatNbr = " + utilData.FormatData(m_strBatNbr, getDataTypeName("BatNbr"));

        try {
            DBConnection.getActiveConnection().createStatement().executeUpdate(strSQL);
        }catch (SQLException ex) {
//            frmaphdr.errMsg = ex.toString();
            Logger.getLogger(clsAPhdr.class.getName()).log(Level.SEVERE, null, ex);
            
            return false;
        }
        return true;
    }

    public boolean getCurrentRow(String strPrimaryKey){
        String strSQL = "SELECT * FROM aphdr WHERE BatNbr = " + utilData.FormatData(strPrimaryKey, getDataTypeName("BatNbr"));
        try {
            ResultSet rsTable = DBConnection.getActiveConnection().createStatement().executeQuery(strSQL);
            rsTable.next();

            m_strBatNbr = rsTable.getString("BatNbr") + "";
            m_strVoucherNbr = rsTable.getString("VoucherNbr") + "";
            m_strVoucherDate = rsTable.getString("VoucherDate") + "";
            m_strTranType = rsTable.getString("TranType") + "";
            m_strRecurrID = rsTable.getString("RecurrID") + "";
            m_strVendorID = rsTable.getString("VendorID") + "";
            m_strSubLedger = rsTable.getString("SubLedger") + "";
            m_strInvoice = rsTable.getString("Invoice") + "";
            m_strInvoiceDate = rsTable.getString("InvoiceDate") + "";
            m_strTermsID = rsTable.getString("TermsID") + "";
            m_strDueDate = rsTable.getString("DueDate") + "";
            m_strTaxableAmount01 = rsTable.getString("TaxableAmount01") + "";
            m_strTaxableAmount02 = rsTable.getString("TaxableAmount02") + "";
            m_strTaxableAmount03 = rsTable.getString("TaxableAmount03") + "";
            m_strTaxableAmount04 = rsTable.getString("TaxableAmount04") + "";
            m_strTotalTaxable01 = rsTable.getString("TotalTaxable01") + "";
            m_strTotalTaxable02 = rsTable.getString("TotalTaxable02") + "";
            m_strTaxAmount01 = rsTable.getString("TaxAmount01") + "";
            m_strTaxAmount02 = rsTable.getString("TaxAmount02") + "";
            m_strTaxAmount03 = rsTable.getString("TaxAmount03") + "";
            m_strTaxAmount04 = rsTable.getString("TaxAmount04") + "";
            m_strTotalTax01 = rsTable.getString("TotalTax01") + "";
            m_strTotalTax02 = rsTable.getString("TotalTax02") + "";
            m_strAmount = rsTable.getString("Amount") + "";
            m_strCreditAmt = rsTable.getString("CreditAmt") + "";
            m_strDetails = rsTable.getString("Details") + "";
            m_strDocType = rsTable.getString("DocType") + "";
            m_strCompanyID = rsTable.getString("CompanyID") + "";
            m_strBranchID = rsTable.getString("BranchID") + "";
            m_strCurrencyCode = rsTable.getString("CurrencyCode") + "";
            m_strExchangeRate = rsTable.getString("ExchangeRate") + "";
            m_strDocStatus = rsTable.getString("DocStatus") + "";
            m_strOKToPost = rsTable.getString("OKToPost") + "";
            m_strPosted = rsTable.getString("Posted") + "";
            m_strVAT = rsTable.getString("VAT") + "";
            m_strWTax = rsTable.getString("WTax") + "";
            m_strTaxable = rsTable.getString("Taxable") + "";
            m_strOffSet = rsTable.getString("OffSet") + "";
            m_strSeqID = rsTable.getString("SeqID") + "";
            
            return true;
        } 
        catch (SQLException ex) {
            frmAPhdr.errMsg = ex.toString();
            Logger.getLogger(clsAPhdr.class.getName()).log(Level.SEVERE, null, ex);
            
            return false;
        }        
    }

    public boolean saveNewRow(String TypeE){

        try {
            if ("ADD".equals(TypeE)) {
                String strSQL = "INSERT INTO " +
                        m_strTableName +
                        " ( " +
                        m_strInsertList +
                        " ) VALUES ( "
                        + utilData.FormatData(m_strBatNbr, getDataTypeName("BatNbr"))
                        + " , " + utilData.FormatData(m_strVoucherNbr, getDataTypeName("VoucherNbr"))
                        + " , " + utilData.FormatData(m_strVoucherDate, getDataTypeName("VoucherDate"))
                        + " , " + utilData.FormatData(m_strTranType, getDataTypeName("TranType"))
                        + " , " + utilData.FormatData(m_strRecurrID, getDataTypeName("RecurrID"))
                        + " , " + utilData.FormatData(m_strVendorID, getDataTypeName("VendorID"))
                        + " , " + utilData.FormatData(m_strSubLedger, getDataTypeName("SubLedger"))
                        + " , " + utilData.FormatData(m_strInvoice, getDataTypeName("Invoice"))
                        + " , " + utilData.FormatData(m_strInvoiceDate, getDataTypeName("InvoiceDate"))
                        + " , " + utilData.FormatData(m_strTermsID, getDataTypeName("TermsID"))
                        + " , " + utilData.FormatData(m_strDueDate, getDataTypeName("DueDate"))
                        + " , " + utilData.FormatData(m_strTaxableAmount01, getDataTypeName("TaxableAmount01"))
                        + " , " + utilData.FormatData(m_strTaxableAmount02, getDataTypeName("TaxableAmount02"))
                        + " , " + utilData.FormatData(m_strTaxableAmount03, getDataTypeName("TaxableAmount03"))
                        + " , " + utilData.FormatData(m_strTaxableAmount04, getDataTypeName("TaxableAmount04"))
                        + " , " + utilData.FormatData(m_strTotalTaxable01, getDataTypeName("TotalTaxable01"))
                        + " , " + utilData.FormatData(m_strTotalTaxable02, getDataTypeName("TotalTaxable02"))
                        + " , " + utilData.FormatData(m_strTaxAmount01, getDataTypeName("TaxAmount01"))
                        + " , " + utilData.FormatData(m_strTaxAmount02, getDataTypeName("TaxAmount02"))
                        + " , " + utilData.FormatData(m_strTaxAmount03, getDataTypeName("TaxAmount03"))
                        + " , " + utilData.FormatData(m_strTaxAmount04, getDataTypeName("TaxAmount04"))
                        + " , " + utilData.FormatData(m_strTotalTax01, getDataTypeName("TotalTax01"))
                        + " , " + utilData.FormatData(m_strTotalTax02, getDataTypeName("TotalTax02"))
                        + " , " + utilData.FormatData(m_strAmount, getDataTypeName("Amount"))
                        + " , " + utilData.FormatData(m_strCreditAmt, getDataTypeName("CreditAmt"))
                        + " , " + utilData.FormatData(m_strDetails, getDataTypeName("Details"))
                        + " , " + utilData.FormatData(m_strDocType, getDataTypeName("DocType"))
                        + " , " + utilData.FormatData(m_strCompanyID, getDataTypeName("CompanyID"))
                        + " , " + utilData.FormatData(m_strBranchID, getDataTypeName("BranchID"))
                        + " , " + utilData.FormatData(m_strCurrencyCode, getDataTypeName("CurrencyCode"))
                        + " , " + utilData.FormatData(m_strExchangeRate, getDataTypeName("ExchangeRate"))
                        + " , " + utilData.FormatData(m_strDocStatus, getDataTypeName("DocStatus"))
                        + " , " + utilData.FormatData(m_strOKToPost, getDataTypeName("OKToPost"))
                        + " , " + utilData.FormatData(m_strPosted, getDataTypeName("Posted"))
                        + " , " + utilData.FormatData(m_strTaxable, getDataTypeName("Taxable"))
                        + " , " + utilData.FormatData(m_strVAT, getDataTypeName("VAT"))
                        + " , " + utilData.FormatData(m_strWTax, getDataTypeName("WTax"))
                        + " , " + utilData.FormatData(m_strOffSet, getDataTypeName("OffSet"))
                        + " , " + "'"+mdlLogin.username+"'"
                        + " , NOW() "
                        + " )";
                DBConnection.getActiveConnection().createStatement().executeUpdate(strSQL);
                return true;
            }
            else if ("EDIT".equals(TypeE)) {
                String strSQL = "UPDATE " +
                        m_strTableName +
                        " SET " +
                        "BatNbr = " + utilData.FormatData(m_strBatNbr, getDataTypeName("BatNbr"))
                        + " , VoucherNbr = " + utilData.FormatData(m_strVoucherNbr, getDataTypeName("VoucherNbr"))
                        + " , VoucherDate = " + utilData.FormatData(m_strVoucherDate, getDataTypeName("VoucherDate"))
                        + " , TranType = " + utilData.FormatData(m_strTranType, getDataTypeName("TranType"))
                        + " , RecurrID = " + utilData.FormatData(m_strRecurrID, getDataTypeName("RecurrID"))
                        + " , VendorID = " + utilData.FormatData(m_strVendorID, getDataTypeName("VendorID"))
                        + " , SubLedger = " + utilData.FormatData(m_strSubLedger, getDataTypeName("SubLedger"))
                        + " , Invoice = " + utilData.FormatData(m_strInvoice, getDataTypeName("Invoice"))
                        + " , InvoiceDate = " + utilData.FormatData(m_strInvoiceDate, getDataTypeName("InvoiceDate"))
                        + " , TermsID = " + utilData.FormatData(m_strTermsID, getDataTypeName("TermsID"))
                        + " , DueDate = " + utilData.FormatData(m_strDueDate, getDataTypeName("DueDate"))
                        + " , TaxableAmount01 = " + utilData.FormatData(m_strTaxableAmount01, getDataTypeName("TaxableAmount01"))
                        + " , TaxableAmount02 = " + utilData.FormatData(m_strTaxableAmount02, getDataTypeName("TaxableAmount02"))
                        + " , TaxableAmount03 = " + utilData.FormatData(m_strTaxableAmount03, getDataTypeName("TaxableAmount03"))
                        + " , TaxableAmount04 = " + utilData.FormatData(m_strTaxableAmount04, getDataTypeName("TaxableAmount04"))
                        + " , TotalTaxable01 = " + utilData.FormatData(m_strTotalTaxable01, getDataTypeName("TotalTaxable01"))
                        + " , TotalTaxable02 = " + utilData.FormatData(m_strTotalTaxable02, getDataTypeName("TotalTaxable02"))
                        + " , TaxAmount01 = " + utilData.FormatData(m_strTaxAmount01, getDataTypeName("TaxAmount01"))
                        + " , TaxAmount02 = " + utilData.FormatData(m_strTaxAmount02, getDataTypeName("TaxAmount02"))
                        + " , TaxAmount03 = " + utilData.FormatData(m_strTaxAmount03, getDataTypeName("TaxAmount03"))
                        + " , TaxAmount04 = " + utilData.FormatData(m_strTaxAmount04, getDataTypeName("TaxAmount04"))
                        + " , TotalTax01 = " + utilData.FormatData(m_strTotalTax01, getDataTypeName("TotalTax01"))
                        + " , TotalTax02 = " + utilData.FormatData(m_strTotalTax02, getDataTypeName("TotalTax02"))
                        + " , Amount = " + utilData.FormatData(m_strAmount, getDataTypeName("Amount"))
                        + " , CreditAmt = " + utilData.FormatData(m_strCreditAmt, getDataTypeName("CreditAmt"))
                        + " , Details = " + utilData.FormatData(m_strDetails, getDataTypeName("Details"))
                        + " , DocType = " + utilData.FormatData(m_strDocType, getDataTypeName("DocType"))
                        + " , CompanyID = " + utilData.FormatData(m_strCompanyID, getDataTypeName("CompanyID"))
                        + " , BranchID = " + utilData.FormatData(m_strBranchID, getDataTypeName("BranchID"))
                        + " , CurrencyCode = " + utilData.FormatData(m_strCurrencyCode, getDataTypeName("CurrencyCode"))
                        + " , ExchangeRate = " + utilData.FormatData(m_strExchangeRate, getDataTypeName("ExchangeRate"))
                        + " , DocStatus = " + utilData.FormatData(m_strDocStatus, getDataTypeName("DocStatus"))
                        + " , OKToPost = " + utilData.FormatData(m_strOKToPost, getDataTypeName("OKToPost"))
                        + " , Posted = " + utilData.FormatData(m_strPosted, getDataTypeName("Posted"))
                        + " , Taxable = " + utilData.FormatData(m_strTaxable, getDataTypeName("Taxable"))
                        + " , VAT = " + utilData.FormatData(m_strVAT, getDataTypeName("VAT"))
                        + " , WTax = " + utilData.FormatData(m_strWTax, getDataTypeName("WTax"))
                        + " , OffSet = " + utilData.FormatData(m_strOffSet, getDataTypeName("OffSet"))
                        + " , UserStamp = " + "'"+mdlLogin.username+"'"
                        + " , TimeStamp = NOW()"
                        + " WHERE BatNbr = " + utilData.FormatData(m_strBatNbr, getDataTypeName("BatNbr"));
                DBConnection.getActiveConnection().createStatement().executeUpdate(strSQL);
                return true;
            }
        }
        catch(Exception ex) {
            frmAPhdr.errMsg = ex.toString();
            Logger.getLogger(clsAPhdr.class.getName()).log(Level.SEVERE, null, ex);
        }
        return false;
    }
    
    public boolean getCurrentData(String strSQL, String strPrimaryKey, String strPrimaryKeyName){
        
        String _sqlCmd2 = strSQL + utilData.FormatData(strPrimaryKey, getDataTypeName(strPrimaryKeyName));
        
        try {
            rsDetail = DBConnection.getActiveConnection().createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY).executeQuery(_sqlCmd2);
            return true;
        } catch (SQLException ex) {
            Logger.getLogger(clsAPhdr.class.getName()).log(Level.SEVERE, null, ex);
            return false;
        }        
    }
}
